package com.lin.cli.pattern;

import java.util.ArrayList;
import java.util.List;

public class RemoteControl {
    private Command command;

    List<Command> commands = new ArrayList<>();

    public void setCommand(Command command) {
        this.command = command;
    }

    public void pressButton() {
        //每次按下一个按钮之后就记录一下
        commands.add(command);
        command.execute();
    }

    /**
     * 回退按钮
     */
    public Command rollbackButton(){
        return commands.remove(commands.size()-1);
    }
}
